<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>{$chapter.book.book_name}-{$chapter.chapter_name}免费阅读-{$site_name}</title>
    <meta name="description" itemprop="description" content="当前阅读的是{$chapter.book.book_name}的{$chapter.chapter_name}">
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" type="text/css" href="/static/css/pc_read.css">
    <link rel="stylesheet" type="text/css" href="/static/css/p.css">

    <style type="text/css">
        .comicpage {
            position: relative;
        }

        .fanye {
            margin-top: 20px;
            margin-bottom: 20px;
        }

        .fanye a {
            background: #FFFFFF;
            border: 1px solid #D9D9D9;
            color: #666666;
            padding: 4px 9px;
        }
    </style>
    {if $next != "null"}
    <link rel="prefetch prerender" href="/{$chapter_ctrl}/{$next.id}"/>
    {/if}
    <script src="https://lib.baomitu.com/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/jquery_lazyload/1.9.7/jquery.lazyload.min.js"></script>
</head>

<body class="read-view">

<div class="container">
    <div id="content">
        <div class="fanye">
            {if $prev == "null"}
            <a class="block" style="color: lightgrey">上一章</a>
            {else/}
            <a href="/{$chapter_ctrl}/{$prev.id}" class="block" title="{$prev.chapter_name}">上一章</a>
            {/if}

            {if $next == "null"}
            <a class="block" style="color: lightgrey">下一章</a>
            {else/}
            <a href="/{$chapter_ctrl}/{$next.id}" class="block" title="{$next.chapter_name}">下一章</a>
            {/if}
        </div>
        <div class="comiclist">
            <div class="comicpage">
                {raccoon:pagedphotos name="photos" pagesize="1" order="id asc" where="chapter_id='$chapter->id'"}
                <div>
                    <img class="lazy" data-original="{$vo.img_url}" src="https://p.pstatp.com/origin/ffa400036691f82c85e5">
                </div>
                {/raccoon:pagedphotos}
            </div>
        </div>
        <div class="fanye">
            {if $prev == "null"}
            <a class="block" style="color: lightgrey">上一章</a>
            {else/}
            <a href="/{$chapter_ctrl}/{$prev.id}" class="block" title="{$prev.chapter_name}">上一章</a>
            {/if}

            {if $page.last_page > 1}
            {if $page.current_page == 1}
            <a class="block" style="color: lightgrey">上一页</a>
            {else/}
            <a class="block" id="prevPage" href="/{$chapter_ctrl}/{$chapter.id}/?page={$page.current_page-1}{$param}" title="上一页">上一页</a>
            {/if}

            {if $page.current_page == $page.last_page}
            <a class="block" style="color: lightgrey">下一页</a>
            {else/}
            <a class="block" id="nextPage" href="/{$chapter_ctrl}/{$chapter.id}?page={$page.current_page+1}{$param}" title="下一页">下一页</a>
            {/if}
            {/if}

            {if $next == "null"}
            <a class="block" style="color: lightgrey">下一章</a>
            {else/}
            <a href="/{$chapter_ctrl}/{$next.id}" class="block" title="{$next.chapter_name}">下一章</a>
            {/if}
        </div>
    </div>
</div>
<!--顶部栏-->
<div class="header">
    <div class="row">
        <div class="crumbs">
            <a href="/" title="{$site_name}">{$site_name}</a> &gt;
            <a class="comic-name" href="/{$book_ctrl}/{$chapter.book.param}" title="{$chapter.book.book_name}">{$chapter.book.book_name}</a>
        </div>
        <h1 class="title">{$chapter.book.book_name} {$chapter.chapter_name}</h1>
        <div class="shareBtn">
            <a href="javascript:void(0)" class="phone">微信中阅读
                <span class="code"><img src="/static/images/wxqrcode.jpg"><p>扫码关注公众号</p></span>
            </a>
        </div>
    </div>
</div>
<div class="read-section sidebar-main" style="left: 0px;">
    <div class="sidebar-header">
        <i class="sidebar-header-l">章节</i>
        <i class="sidebar-header-r">共{$chapter.book.chapter_count}话</i>
    </div>
    <div class="sidebar-content">
        <div class="slimScrollDiv" style="position: relative; overflow: hidden; width: auto; height: 357px;">
            <div class="mCustomScrollBox" style="overflow: hidden;width: auto;height: 519px;overflow-y: scroll;">
                <ul>
                    {raccoon:chapters name="chapters" where="book_id='$chapter->book_id'" order="chapter_order asc"}
                    <li>
                        <a href="/{$chapter_ctrl}/{$vo.id}">
                            {$vo.chapter_name}
                        </a>
                    </li>
                    {/raccoon:chapters}
                </ul>
            </div>
            <div class="slimScrollBar"
                 style="background: rgb(0, 0, 0); width: 7px; position: absolute; top: 0px; opacity: 0.4; display: none; border-radius: 7px; z-index: 99; right: 1px; height: 30px;"></div>
            <div class="slimScrollRail"
                 style="width: 7px; height: 100%; position: absolute; top: 0px; display: none; border-radius: 7px; background: rgb(51, 51, 51); opacity: 0.2; z-index: 90; right: 1px;"></div>
        </div>
    </div>
    <div class="sidebar-btn"><i class="read-icon-list"></i>章<br>节</div>
</div>
<script src="/static/js/swiper2.min.js"></script>
<script src="/static/js/index.js"></script>
<script src="/static/js/jquery.slimscroll.min.js"></script>
<script>
    $(function () {
        $('.mCustomScrollBox').slimScroll({
            height: 'auto'
        });
        $("img.lazy")
            .lazyload({
                threshold: 360,
                event: "lazyload",
                effect: "fadeIn",
                effectspeed: 2000
            })
            .trigger("lazyload");

        $('.sidebar-btn').click(function () { //给触发按钮绑定点击事件，也就是鼠标点击触发按钮后执行的动作
            if ($('.read-section').css('left') == "0px")
                $('.read-section').animate({left: '-212px'}, 200); //把左边栏的宽度设置为原来的宽度并显示出来， 根据设定的时间慢慢展现
            else
                $('.read-section').animate({left: '0px'}, 200); //把左边栏的宽度设置为原来的宽度并显示出来， 根据设定的时间慢慢展现
        });

        //--本地缓存代码开始--
        let bookInfo = {
            chapter_id: '{$chapter.id}',
            end: "{$chapter.book.end == 1 ? '完结' : '连载'}",
            chapter_name: '{$chapter.chapter_name}',
            cover_url:'{$chapter.book.cover_url}',
            book_id: '{$chapter.book_id}',
            last_time: "{$chapter.book.last_time|date='Y-m-d'}",
            book_name:'{$chapter.book.book_name}',
            param: '{$chapter.book.param}'
        };
        localStorage.setItem('manhua_{$chapter.book_id}', JSON.stringify(bookInfo));//id为键，设置缓存
        let history = [];
        let value = localStorage.getItem('xwx_historys'); //读取参照数组
        if (value != undefined && value != null) {
            history = JSON.parse(value);
        }
        if (history.indexOf('manhua_{$chapter.book_id}') === -1) {
            history.push('manhua_{$chapter.book_id}'); //把id为值存入参照数组
        }

        console.log(history)
        localStorage.setItem('xwx_historys', JSON.stringify(history));
        //--本地缓存代码结束--

        document.body.oncopy = function () {
            return false;
        }; //阻止复制
        document.body.onselectstart = function () {
            return false;
        }; //阻止选中
        document.oncontextmenu = function () {
            return false;
        }; //阻止菜单弹出
        if (document.images) {
            for (i = 0; i < document.images.length; i++) {
                document.images[i].onmousedown = function () {
                    return false;
                };
            }
        }
    });

</script>
{include file="./template/default/pc/pub/others.html"}
</body>

</html>